package com.david.nfc.result

import android.content.Context
import org.json.JSONObject
import java.util.*

object NfcParserUtil {
    private val parsers: ArrayList<NfcParser> = ArrayList()
    init {
        parsers.add(MusicParser())
    }
    fun parseResult(context: Context, content: String): Boolean{
        val jsonObj = JSONObject(content)
        val resultBean = NfcResultBean(jsonObj.getString("type"), jsonObj.getString("action"))
        for (item in parsers) {
            if (item.parseResult(context, resultBean)) {
                return true
            }
        }
        return false
    }
}